import java.util.*;

public class Test implements Comparator<Test>,Comparable<Test>{
    @Override
    public int compare(Test o1, Test o2) {
        return o1.a-o2.a;
    }
    @Override
    public int compareTo(Test o) {
        return this.a - o.a;
    }
    int a;
    String b;
    public Test(){

    }
    public Test(int val,String str){
        this.a = val;
        this.b = str;
    }
    public static void main(String[] args) {
        Test test = new Test();
        Test test1 = new Test(1,"a");
        Test test2 = new Test(2,"b");
        System.out.println(test.compare(test1, test2));
        System.out.println(test1.compareTo(test2));
    }

    public static void main5(String[] args) {
        int[] arr = {1,2,3,4,5,6};
        System.out.println(Arrays.toString(arr));
    }
    public static void main4(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(2);
        list.add(1);
        list.add(3);
        list.add(4);
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(list);
        System.out.println(priorityQueue.size());
        System.out.println(priorityQueue.peek());
        System.out.println(priorityQueue);
    }

    public static void main3(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(2);
        priorityQueue.offer(9);
        priorityQueue.offer(6);
        System.out.println(priorityQueue);
        char[] arr = {'1','2','3'};
        System.out.println(arr);
        String s = String.valueOf(arr);
        System.out.println(s);
    }

    public static void main2(String[] args) {
        //实现大根堆的方法之一，通过内部类
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });
    }

    public static void main1(String[] args) {
        MyPriorityQueue myPriorityQueue = new MyPriorityQueue();
        myPriorityQueue.maxSort();
        for (int x:myPriorityQueue.arr) {
            System.out.print(x+" ");
        }
        System.out.println();
        myPriorityQueue.add(80);
        for (int x:myPriorityQueue.arr) {
            System.out.print(x+" ");
        }
        System.out.println();
        myPriorityQueue.delete();
        for (int x:myPriorityQueue.arr) {
            System.out.print(x+" ");
        }
    }
}
